package com.lqk.testnewflutter.flutter

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.fragment.app.FragmentActivity
import com.lqk.testnewflutter.R
import com.lqk.testnewflutter.databinding.ViewFlutterBinding

/**
 *
 * @auther LQK 2025-06-22 10:29
 */
class FlutterContentView : FragmentActivity() {

    lateinit var vm: ViewFlutterBinding

    val flutterFragment: TestFlutterFragment = TestFlutterFragment()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        vm = ViewFlutterBinding.inflate(layoutInflater)
        setContentView(vm.root)

        supportFragmentManager.beginTransaction()
            .add(R.id.fm_flutter_container, flutterFragment)
            .commit()

        initEvent()

    }

    fun initEvent(){
        vm.tvTest.setOnClickListener {
            flutterFragment.send2Flutter("A", 1)
        }
        vm.tvTestBasic.setOnClickListener {
            flutterFragment.sendMessage("ooo")
        }
        vm.tvTestBinary.setOnClickListener {
            flutterFragment.sendBinaryMessenger()
        }
    }

}